// Component 接口
interface Component {
    void operation();
    void add(Component component);
    void remove(Component component);
    Component getChild(int index);
}

// Leaf 类
class Leaf implements Component {
    public void operation() {
        System.out.println("Leaf operation");
    }
    
    public void add(Component component) {
        // Do nothing
    }
    
    public void remove(Component component) {
        // Do nothing
    }
    
    public Component getChild(int index) {
        return null;
    }
}

// Composite 类
class Composite implements Component {
    private Component[] components;
    
    public Composite(int size) {
        components = new Component[size];
    }
    
    public void operation() {
        for (Component component : components) {
            component.operation();
        }
    }
    
    public void add(Component component) {
        // Add component to the array
    }
    
    public void remove(Component component) {
        // Remove component from the array
    }
    
    public Component getChild(int index) {
        return components[index];
    }
}

// 测试类
public class CompositeTest {
    public static void main(String[] args) {
        Composite root = new Composite(4);
        Component leaf1 = new Leaf();
        Component leaf2 = new Leaf();
        root.add(leaf1);
        root.add(leaf2);
        root.operation(); // 输出：Leaf operation
                            //        Leaf operation
    }
}